package com.ychug.gateway.system;


import com.ychug.common.base.ResultAjaxHash;
import com.ychug.framework.web.base.BaseController;
import com.ychug.framework.web.page.TableDataInfo;
import com.ychug.service.system.entity.SysOperLogEntity;
import com.ychug.service.system.service.ISysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 操作日志记录
 * 
 * @author ruoyi
 */
@Controller
@RequestMapping("/sys/operlog")
public class SysOperlogController extends BaseController
{
    private String prefix = "modules/sys/operlog";

    @Autowired
    private ISysOperLogService operLogService;


    @GetMapping()
    public String operlog()
    {
        return prefix + "/viewOperlog";
    }


    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysOperLogEntity operLog)
    {
        startPage();
        List<SysOperLogEntity> list = operLogService.selectOperLogList(operLog);
        return getDataTable(list);
    }


    @PostMapping("/export")
    @ResponseBody
    public ResultAjaxHash export(SysOperLogEntity operLog)
    {
//        List<SysOperLogEntity> list = operLogService.selectOperLogList(operLog);
//        ExcelUtil<SysOperLog> utils = new ExcelUtil<SysOperLogEntity>(SysOperLog.class);
//        return utils.exportExcel(list, "operLog");
        return  null;
    }


    @PostMapping("/remove")
    @ResponseBody
    public ResultAjaxHash remove(String ids)
    {
        return toAjax(operLogService.deleteOperLogByIds(ids));
    }


    @GetMapping("/detail/{operId}")
    public String detail(@PathVariable("operId") Long operId, ModelMap mmap)
    {
        mmap.put("operLog", operLogService.selectOperLogById(operId));
        return prefix + "/detailLog";
    }
    

    @PostMapping("/clean")
    @ResponseBody
    public ResultAjaxHash clean()
    {
        operLogService.cleanOperLog();
        return success();
    }
}
